package com.example.a2209_mianshi.ui.mall.model

import com.chad.library.adapter.base.entity.MultiItemEntity
class MallGoodModel : ArrayList<MallGoods>()
class MallBannerModel : ArrayList<MallBanner>()
object MallRowTypes{
    const val TITLE = 0
    const val SECKILL_TITLE = 1
    const val BANNER = 2
    //第三方服务二手车，跳蚤市场
    const val THIRD_SERVICE = 22
    // 热门活动
    const val ACTIVITY = 3

    // 秒杀&商品
    const val SECKILL = 4
    const val GOODS = 5

    // 系列大图
    const val PIC = 6

    // 系列富文本
    const val RICH_TXT = 7

    // 推荐商品:最多8个 可以滑动
    const val RECOMMEND = 8

    // 系列
    const val SERIES_PIC_BIG = 11// 大图-方图
    const val SERIES_PIC_SMALL = 12// 一行2个-方图
    const val SERIES_PIC_RECT = 21// 1行1个-长图
}
class MallHomeRowItem(
    var type : Int,
    var title : String? = null,
    var id : Long = 0,
    var tag : String? = null,
    var banners : List<MallBanner>? = null,
    var goods : MallGoods? = null,
    var goodsList : ArrayList<MallGoods>? = null,
    var pic : String? = null,
    var richText : String? = ""
):MultiItemEntity{
    fun getSpanSize(): Int {
        return when (type) {
            MallRowTypes.GOODS, MallRowTypes.SECKILL, MallRowTypes.SERIES_PIC_SMALL -> 1
            else -> 2
        }
    }

    override val itemType: Int
        get() = type
}
class MallBanner(
    var id : Long = 0,
    var imageUrl : String = "",
    var name :String? = "",
    var productType : String? = "",
    var type : String? = "",
    var url : String? = "",
    var dataId : Int? = 0
)
open class MallGoods(
    val code: String,
    val createTime: String,
    val id: Int,
    val mallGoodsInfoPageResponseList: List<MallGoodsInfoPageResponse>,
    val name: String,
    val operIdCreate: Int,
    val operIdMod: Int,
    val operNameCreate: String,
    val operNameMod: String,
    val parentId: Int,
    val parentName: String,
    val remark: String,
    val sort: Int,
    val type: String,
    val updateTime: String,
    val imageUrl:String
)
//):MultiItemEntity{
//    fun priceInt(): String {
//        return mallGoodsInfoPageResponseList[0].purchasePrice.toInt().toString()
//    }
//
//    fun priceFloat(): String {
//        val ps = purchasePrice.formatDecimal(2)
//        val til = if (priceUp || multiSkuPrice()) " 起" else ""
//        return ".${ps.split(".").last()}".replace(".00", "") + til
//    }
//
//}

data class MallGoodsInfoPageResponse(
    val brandCode: String,
    val brandName: String,
    val createTime: String,
    val goodsCode: String,
    val group: Group,
    val id: Int,
    val mainImgUrl: String,
    val marketPriceFee: Int,
    val modelCode: String,
    val modelName: String,
    val operIdCreate: Any,
    val operIdMod: Any,
    val operNameCreate: String,
    val operNameMod: String,
    val productType: String,
    val purchasePrice: Int,
    val soldNum: Int,
    val title: String,
    val tlineCode: String,
    val tlineName: String,
    val updateTime: String
)

data class Group(
    val code: String,
    val createTime: String,
    val id: Int,
    val name: String,
    val operIdCreate: Int,
    val operIdMod: Int,
    val operNameCreate: String,
    val operNameMod: String,
    val parentId: Int,
    val parentName: String,
    val remark: String,
    val sort: Int,
    val type: String,
    val updateTime: String
)